package com.example.room.dao;

import com.example.room.entity.Team;

import java.util.List;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

/**
 * author: WangJunYan
 * package: com.example.wjy.room
 * date: 2020/6/19
 * time: 13:44
 * room的组件之一，用于通过room直接与本地数据库交互
 */
@Dao
public interface TeamDao {

    /**
     * 获取Team表中所有数据,用LiveData承载，自动更新.
     * Query中的字符串表示SQL语句.
     * @return all data of table Team
     */
    @Query("SELECT * FROM Team")
    LiveData<List<Team>> getAllTeam();

    /**
     * 插入数据，参数可以有多个
     * @param teams teams to be inserted
     */
    @Insert
    void insertTeam(Team... teams);

    @Delete
    void deleteTeam(Team... teams);

    @Query("delete from team")
    void deleteTeam();

    @Update
    void modify(Team... teams);
}
